package top.canyue.word_range_service.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.canyue.word_range.pojo.po.Review;
import top.canyue.word_range.pojo.po.WordMapping;
import top.canyue.word_range.result.Result;
import top.canyue.word_range_service.service.ReviewService;

import java.util.List;

/**
 * 学习复习相关接口
 * <p>学习新词和复习旧词的相关接口都放这，方便管理</p>
 */

@RestController
@RequestMapping(value = "/apiV1/review")
@RequiredArgsConstructor
public class ReviewController {
    final private ReviewService reviewService;

    /**
     * 存储学习数据
     */
    @PostMapping("/saveOrUpdateReview")
    Result<Review> saveOrUpdateReview(@RequestHeader String JWT, String word){
        return reviewService.saveOrUpdateReview(word);
    }

    /**
     * 获取随机新单词列表
     */
    @GetMapping("/getRandomNewWordList")
    public Result<List<WordMapping>> getRandomNewWordList(@RequestHeader String JWT, String bookId, Integer count){
        return reviewService.getRandomNewWordList(bookId, count);
    }


    /**
     * 获取随机复习单词列表
     */
    @GetMapping("/getRandomReviewWordList")
    public Result<List<WordMapping>> getRandomReviewWordList(@RequestHeader String JWT, String bookId, Integer count){
        return reviewService.getRandomReviewWordList(bookId, count);
    }

    /**
     * 复习活动获取单词列表的接口
     */
    @GetMapping("/getRandomReviewWordListByEvent")
    public Result<List<WordMapping>> getRandomReviewWordListByEvent(@RequestHeader String JWT, Integer count){
        return reviewService.getRandomReviewWordListByEvent(count);
    }

    /**
     * 当前用户已过招单词数量
     */
    @GetMapping("/getReviewedWordCount")
    public Result<Long> getReviewedWordCount(@RequestHeader String JWT){
        return reviewService.getReviewedWordCount(JWT);
    }

    /**
     * 当前用户已掌握的单词数量
     */
    @GetMapping("/getMasteredWordCount")
    public Result<Long> getMasteredWordCount(@RequestHeader String JWT){
        return reviewService.getMasteredWordCount(JWT);
    }
}
